const http = require('http')
const https = require('https');
const cheerio = require('cheerio')

let data = ''
function getData(params) {
    $ = cheerio.load(params)
    let doc = $('.site-header .children-list')

    doc.each((index, item) => {
        console.log($(item).find('.title').text().replace(/^\s|\s$/, ''));
    });
}
const server = http.createServer((req, rep) => {
    https.get("https://www.mi.com", (res) => {
        res.on('data', (chunk) => {
            data += chunk
        })
        res.on('end', () => {
            getData(data)
        })
    })
})
server.listen(8082)
